﻿
using Knlght.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knight.Models.Entity
{
    /// <summary>
    /// 文章信息
    /// </summary>
    public class NewsInfo:TEntityBase
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 文章类型
        /// </summary>
        public int OwmTypeId { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 小标题
        /// </summary>
        public string SmallTitle { get; set; }
        /// <summary>
        /// 描述----列表页短篇描述
        /// </summary>
        public string Describe { get; set; }
        /// <summary>
        /// Seo关键字
        /// </summary>
        public string SeoKey { get; set; }
        /// <summary>
        /// Seo描述
        /// </summary>
        public string SeoDescription { get; set; }
        /// <summary>
        /// 作者出处
        /// </summary>
        public string Editor { get; set; }       
        /// <summary>
        /// 排序坐标
        /// </summary>
        public int DisplayIndex { get; set; }
        /// <summary>
        /// 点击数
        /// </summary>
        public int Hot { get; set; }
        /// <summary>
        /// 预览图
        /// </summary>
        public string ImageUrl { get; set; }
        /// <summary>
        /// 图片宽度
        /// </summary>
        public int ImageWidth { get; set; }
        /// <summary>
        /// 图片高度
        /// </summary>
        public int ImageHeight { get; set; }       
        /// <summary>
        /// 文章内容
        /// </summary>
        public string Content { get; set; }       
        /// <summary>
        /// 是否显示
        /// </summary>
        public bool IsShow { get; set; }
        /// <summary>
        /// 是否置顶
        /// </summary>
        public bool IsTop { get; set; }
        /// <summary>
        /// 是否置首
        /// </summary>
        public bool IsHome { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime AddTime { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }
    }

    public class NewsInfoMapping : EntityTypeConfiguration<NewsInfo>
    {
        public NewsInfoMapping()
        {
            // 设置表名
            this.ToTable("T" + nameof(NewsInfo));
            //设置主键
            this.HasKey(a => a.Id);
            //自增
            this.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            //不更新
            this.Property(t => t.AddTime).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
            // 设置属性的类型和长度
            this.Property(a => a.Title).HasColumnType("NVarchar").HasMaxLength(900);
            this.Property(a => a.SmallTitle).HasColumnType("NVarchar").HasMaxLength(600);
        }
    }
}
